#include "Date.h"
using namespace std;
int main()
{
    try {
        Date d1;//d1默认为1970.1.1
        cout << d1.year() << "-" << d1.month() << "-" << d1.day() << endl;

        Date d2(2020,1,23);//d2为2020.1.23
        cout << d2.string_rep() << endl; //d2转化为string输出

        Date::set_default(2019,2,28);//default设置为2019.2.28
        Date d3;//d3默认为2019.2.28

        char ch[10] = { '\0'};
        d3.char_rep(ch);//d3赋值到ch数组
        for (int i = 0; i < 10; i++)
        {
            cout << ch[i];  //输出d3:2019.2.28
        }

        d3.add_day(31);//d3为2019.3.31
        cout << endl << d3.string_rep() << endl;
        d3.add_month(11);//d3为2020.2.29
        cout << d3.string_rep() << endl;


        Date::set_default(2019, 2, 29);//非法日期，报错
      }
      catch (Date::Bad_date) {
               cout << endl<<"A bad date!\n" << endl;
    }

    return 0;
}

